package com.kx.yooli.kx.wechat.config.menu;

import com.kx.yooli.kx.wechat.constant.Constants;
import com.kx.yooli.kx.wechat.po.menu.MenuPo;
import com.kx.yooli.kx.wechat.utils.comm.GsonUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author john_sqwen-childe.wen
 * @date 2024/4/1
 * @PROJECT_NAME wechat
 * @description create MenuConfig by john_sqwen
 * and menuConf value is
 */
public class MenuConfig {
    private final Logger log = LoggerFactory.getLogger(MenuConfig.class);

    public static int createMenu(MenuPo menu ,String accessToken){
        int result = 0;
        // 拼装创建菜单的url
        String url = Constants.MENU_CREATE_URL.replace("ACCESS_TOKEN", accessToken);
        // 将菜单对象转换成 json 字符串
        String jsonMenu = GsonUtils.gsonString(menu);
        // 调用接口创建菜单
//        JSONObject jsonObject = WechatUtil.httpRequest(url, Constants.Request_Method_Post, jsonMenu);
//        if (null != jsonObject) {
//            if (0 != jsonObject.getIntValue("errcode")) {
//                result = jsonObject.getIntValue("errcode");
//                String error = String.format("创建菜单失败 errcode:{%s} errmsg:{%s}",
//                        jsonObject.getIntValue("errcode"),
//                        jsonObject.getString("errmsg"));
//                log.error(error);
//            }
//        }
        return result;
      //  return 1;
    }
}
